import 'dart:async';
import 'package:lx_widgets_library/lx_widgets_library.dart';
import 'package:wechat_assets_picker_plus/wechat_assets_picker_plus.dart';

import '../package_event.dart';

// 上传资源图片
class UploadAsssetUtil {
  // 上传
  static Future<AssetModel> upload(AssetModel asset) {
    final controller = StreamController<AssetModel>();
    // 上传资源文件
    PackageEvent.uploadAsssets(
      (fileName) {
        controller.add(asset..src = AssetModel.getUrl(OSS_FILE_URL, fileName));
      },
      param: asset.filePath,
    );
    return controller.stream.first;
  }
}
